package auctionhaus

class BidService {

    def addBid(Listing listing, Customer bidder, double amount) {
        def bidInstance = new Bid(listing: listing, bidder: bidder, amount: amount)
        if(!listing.bids) {
            listing.bids = new HashSet<Bid>()
        }
        listing.bids.add(bidInstance)
        listing.save(flush: true)
        return bidInstance
    }
}
